package com.drpclub.gamebackend.common.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import static com.drpclub.gamebackend.common.constant.Const.ACCESSPATH;

/**
 * @author ：drp
 * @date ：Created in 2020/5/23 10:27
 * @description：
 * @modified By：
 * @version: $
 */

@Slf4j
@Configuration
public class MyWebMvcConfigure implements WebMvcConfigurer {
    @Value ("${filePath}")
    public String uploadPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler (String.format ("%s**", ACCESSPATH)).addResourceLocations ("file:" + uploadPath);
    }
}
